package com.foreknow.demo12;

/**
 * == 与 equals的区别
 *
 * == 引用类型使用==比较的是内存地址
 * equals 比较的是内容
 */
public class EqualsDemo {
    public static void main(String[] args) {
        String s1 = "haha";
        String s2 = "haha";
        String s3 = new String("haha");
        String s4 = new String("haha");
        String s5 = "ha"+"ha";
        String s6 = new String("ha")+"ha";

        System.out.println(s1 == s2);
        System.out.println(s1 == s3);
        System.out.println(s3.equals(s4));
        System.out.println(s1 == s5);
        System.out.println(s1 == s6);
    }
}
